package com.wugui.datax.admin.service.impl;

import com.wugui.datax.admin.service.LdapService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.filter.EqualsFilter;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
@Slf4j
public class LdapServiceImpl implements LdapService {
    @Resource
    private LdapTemplate ldapTemplate;


    @Override
    public boolean ldapLogin(String userName,String password) {
        EqualsFilter filter = new EqualsFilter("uid", userName);
        return ldapTemplate.authenticate("", filter.toString(), password);
    }

}
